//
//  LMHelpViewController.m
//  彩票
//
//  Created by 张青花 on 15/9/28.
//  Copyright (c) 2015年 李明. All rights reserved.
//

#import "LMHelpViewController.h"
#import "LMHtmlPage.h"
#import "LMwebVIewController.h"
@interface LMHelpViewController ()

@property (nonatomic,strong)NSArray *htmls;

@end

@implementation LMHelpViewController

- (NSArray *)htmls
{
    if (_htmls == nil) {
        
        
        NSString *path = [[NSBundle mainBundle] pathForResource:@"help" ofType:@"json"];
        NSData *data = [NSData dataWithContentsOfFile:path];
        
        NSArray *object =[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
        
        NSMutableArray *htmlss = [NSMutableArray array];
        
        for (NSDictionary *dic in object) {
            LMHtmlPage *page = [LMHtmlPage htmlpageWithDic:dic];
            [htmlss addObject:page];
        }
        _htmls = htmlss;
        
    }
    return _htmls;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    LMSettingObjectGroup *group = [[LMSettingObjectGroup alloc] init];
    
    NSMutableArray *items = [NSMutableArray array];
    for (LMHtmlPage *html in self.htmls) {
        LMSettingObject *object = [LMSettingObject SettingObjectWithIcon:nil title:html.title type:@"1"];
        
        [items addObject:object];
        
    }
    group.items = items;
    
    
    [self.settingitemArray addObject:group];

}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    LMwebVIewController *web = [[LMwebVIewController alloc] init];
    
    web.htmlPage = self.htmls[indexPath.row];
    
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:web];
    
    
    [self presentViewController:nav animated:YES completion:nil];
}

@end
